define(
	[
		'require',
		'broada/base/text!./template.hbs'
	],
	function (require) {
		"use strict";
		var tpl = require('broada/base/text!./template.hbs');
		var ExportFormView= Ember.Component.extend({
			layout: Ember.HTMLBars.compile(tpl),
			didInsertElement: function(){
		        this.updateConfig();
			},
			updateConfig:function() {
		          var options = {};
		          var ctrl = this.get("controller");
				  var $viewRoot = this.$().find('a');
		          $viewRoot.click(function(){
		          	 var str = ctrl.get("data");  
			         str =  encodeURIComponent(str);  
			         this.href = "data:text/csv;charset=utf-8,"+str;
		          });
	        }
			
			
		});

		return ExportFormView;
	}
);